{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From <ipython-input-1-1cf59092d567>:3: read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use alternatives such as official/mnist/dataset.py from tensorflow/models.\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please write your own downloading logic.\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:262: extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use tf.data to implement this functionality.\n",
      "Extracting MNIST_data\\train-images-idx3-ubyte.gz\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:267: extract_labels (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use tf.data to implement this functionality.\n",
      "Extracting MNIST_data\\train-labels-idx1-ubyte.gz\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:110: dense_to_one_hot (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use tf.one_hot on tensors.\n",
      "Extracting MNIST_data\\t10k-images-idx3-ubyte.gz\n",
      "Extracting MNIST_data\\t10k-labels-idx1-ubyte.gz\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:290: DataSet.__init__ (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use alternatives such as official/mnist/dataset.py from tensorflow/models.\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "from tensorflow.examples.tutorials.mnist import input_data\n",
    "mnist = input_data.read_data_sets('MNIST_data', one_hot=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From <ipython-input-2-66fb6199d7e0>:52: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "\n",
      "Future major versions of TensorFlow will allow gradients to flow\n",
      "into the labels input on backprop by default.\n",
      "\n",
      "See @{tf.nn.softmax_cross_entropy_with_logits_v2}.\n",
      "\n",
      "Iter: 0, acc: 0.9794\n",
      "Iter: 1, acc: 0.9887\n",
      "Iter: 2, acc: 0.9871\n",
      "Iter: 3, acc: 0.9885\n",
      "Iter: 4, acc: 0.9903\n",
      "Iter: 5, acc: 0.9923\n",
      "Iter: 6, acc: 0.9869\n",
      "Iter: 7, acc: 0.9921\n",
      "Iter: 8, acc: 0.9899\n",
      "Iter: 9, acc: 0.9906\n",
      "Iter: 10, acc: 0.9907\n",
      "Iter: 11, acc: 0.9888\n",
      "Iter: 12, acc: 0.9919\n",
      "Iter: 13, acc: 0.9918\n",
      "Iter: 14, acc: 0.9915\n",
      "Iter: 15, acc: 0.9916\n",
      "Iter: 16, acc: 0.9905\n",
      "Iter: 17, acc: 0.99\n",
      "Iter: 18, acc: 0.9913\n",
      "Iter: 19, acc: 0.9905\n",
      "Iter: 20, acc: 0.9918\n"
     ]
    }
   ],
   "source": [
    "batch_size = 100\n",
    "n_batch = mnist.train.num_examples // batch_size\n",
    "\n",
    "def weight_variable(shape):\n",
    "    return tf.Variable(tf.truncated_normal(shape,stddev=0.1))\n",
    "\n",
    "def bias_vairable(shape):\n",
    "    return tf.Variable(tf.constant(0.1, shape=shape))\n",
    "\n",
    "def conv2d(x,W):\n",
    "    return tf.nn.conv2d(x,W,strides=[1,1,1,1],padding='SAME')\n",
    "\n",
    "def max_pool_2x2(x):\n",
    "    return tf.nn.max_pool(x,ksize=[1,2,2,1],strides=[1,2,2,1],padding='SAME')\n",
    "\n",
    "x = tf.placeholder(tf.float32,[None,784])\n",
    "y = tf.placeholder(tf.float32,[None,10])\n",
    "keep_prob = tf.placeholder(tf.float32)\n",
    "\n",
    "x_image = tf.reshape(x,[-1,28,28,1])\n",
    "\n",
    "W_conv1 = weight_variable([5,5,1,32]) # 5*5的采样窗口，32个卷积核从1个平面抽取特征\n",
    "b_conv1 = bias_vairable([32]) #每个卷积核一个偏置值\n",
    "\n",
    "# 28*28*1 的图片卷积之后变为28*28*32\n",
    "h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)\n",
    "# 池化之后变为 14*14*32\n",
    "h_pool1 = max_pool_2x2(h_conv1)\n",
    "\n",
    "# 第二次卷积之后变为 14*14*64\n",
    "W_conv2 = weight_variable([5,5,32,64])\n",
    "b_conv2 = bias_vairable([64])\n",
    "h_conv2 = tf.nn.relu(conv2d(h_pool1,W_conv2) + b_conv2)\n",
    "# 第二次池化之后变为 7*7*64\n",
    "h_pool2 = max_pool_2x2(h_conv2)\n",
    "\n",
    "\n",
    "# 第一个全连接层\n",
    "W_fc1 = weight_variable([7*7*64,1024])\n",
    "b_fc1 = bias_vairable([1024])\n",
    "# 7*7*64的图像变成1维向量\n",
    "h_pool2_flat = tf.reshape(h_pool2,[-1,7*7*64])\n",
    "h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1)\n",
    "h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob)\n",
    "\n",
    "# 第二个全连接层\n",
    "W_fc2 = weight_variable([1024,10])\n",
    "b_fc2 = bias_vairable([10])\n",
    "logits = tf.matmul(h_fc1_drop,W_fc2) + b_fc2\n",
    "prediction = tf.nn.sigmoid(logits)\n",
    "\n",
    "loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y, logits=logits))\n",
    "train_step = tf.train.AdamOptimizer(0.001).minimize(loss)\n",
    "\n",
    "prediction_2 = tf.nn.softmax(prediction)\n",
    "correct_prediction = (tf.equal(tf.argmax(prediction_2,1), tf.argmax(y,1)))\n",
    "accuracy = tf.reduce_mean(tf.cast(correct_prediction,tf.float32))\n",
    "\n",
    "with tf.Session() as sess:\n",
    "    sess.run(tf.global_variables_initializer())\n",
    "    for epoch in range(21):\n",
    "        for batch in range(n_batch):\n",
    "            batch_xs, batch_ys = mnist.train.next_batch(batch_size)\n",
    "            sess.run(train_step, feed_dict={x:batch_xs,y:batch_ys,keep_prob:0.7})\n",
    "        acc = sess.run(accuracy, feed_dict={x:mnist.test.images, y:mnist.test.labels, keep_prob:1.0})\n",
    "        print(\"Iter: \" + str(epoch) + \", acc: \" + str(acc))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 作业，重构代码，使得Tensorboard查看方便"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From <ipython-input-1-1cf59092d567>:3: read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use alternatives such as official/mnist/dataset.py from tensorflow/models.\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please write your own downloading logic.\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:262: extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use tf.data to implement this functionality.\n",
      "Extracting MNIST_data\\train-images-idx3-ubyte.gz\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:267: extract_labels (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use tf.data to implement this functionality.\n",
      "Extracting MNIST_data\\train-labels-idx1-ubyte.gz\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:110: dense_to_one_hot (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use tf.one_hot on tensors.\n",
      "Extracting MNIST_data\\t10k-images-idx3-ubyte.gz\n",
      "Extracting MNIST_data\\t10k-labels-idx1-ubyte.gz\n",
      "WARNING:tensorflow:From D:\\SoftWare\\Anaconda3\\envs\\pyDL\\lib\\site-packages\\tensorflow\\contrib\\learn\\python\\learn\\datasets\\mnist.py:290: DataSet.__init__ (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use alternatives such as official/mnist/dataset.py from tensorflow/models.\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "from tensorflow.examples.tutorials.mnist import input_data\n",
    "mnist = input_data.read_data_sets('MNIST_data', one_hot=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From <ipython-input-2-4fc6ec955cae>:95: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "\n",
      "Future major versions of TensorFlow will allow gradients to flow\n",
      "into the labels input on backprop by default.\n",
      "\n",
      "See @{tf.nn.softmax_cross_entropy_with_logits_v2}.\n",
      "\n",
      "Step: 0, acc: 0.0818\n",
      "Step: 10, acc: 0.4751\n",
      "Step: 20, acc: 0.7019\n",
      "Step: 30, acc: 0.8307\n",
      "Step: 40, acc: 0.8792\n",
      "Step: 50, acc: 0.9066\n",
      "Step: 60, acc: 0.9214\n",
      "Step: 70, acc: 0.9319\n",
      "Step: 80, acc: 0.9378\n",
      "Step: 90, acc: 0.9429\n",
      "Step: 100, acc: 0.9514\n",
      "Step: 110, acc: 0.9472\n",
      "Step: 120, acc: 0.9536\n",
      "Step: 130, acc: 0.9522\n",
      "Step: 140, acc: 0.96\n",
      "Step: 150, acc: 0.96\n",
      "Step: 160, acc: 0.9591\n",
      "Step: 170, acc: 0.9681\n",
      "Step: 180, acc: 0.9598\n",
      "Step: 190, acc: 0.9669\n",
      "Step: 200, acc: 0.9696\n",
      "Step: 210, acc: 0.973\n",
      "Step: 220, acc: 0.9717\n",
      "Step: 230, acc: 0.974\n",
      "Step: 240, acc: 0.968\n",
      "Step: 250, acc: 0.9728\n",
      "Step: 260, acc: 0.9746\n",
      "Step: 270, acc: 0.9721\n",
      "Step: 280, acc: 0.9682\n",
      "Step: 290, acc: 0.9715\n",
      "Step: 300, acc: 0.9752\n",
      "Step: 310, acc: 0.9756\n",
      "Step: 320, acc: 0.9747\n",
      "Step: 330, acc: 0.9754\n",
      "Step: 340, acc: 0.9785\n",
      "Step: 350, acc: 0.981\n",
      "Step: 360, acc: 0.9775\n",
      "Step: 370, acc: 0.9741\n",
      "Step: 380, acc: 0.9736\n",
      "Step: 390, acc: 0.977\n",
      "Step: 400, acc: 0.9746\n",
      "Step: 410, acc: 0.9765\n",
      "Step: 420, acc: 0.9797\n",
      "Step: 430, acc: 0.9766\n",
      "Step: 440, acc: 0.9829\n",
      "Step: 450, acc: 0.9833\n",
      "Step: 460, acc: 0.9842\n",
      "Step: 470, acc: 0.9806\n",
      "Step: 480, acc: 0.9766\n",
      "Step: 490, acc: 0.9827\n",
      "Step: 500, acc: 0.9834\n",
      "Step: 510, acc: 0.9844\n",
      "Step: 520, acc: 0.983\n",
      "Step: 530, acc: 0.9804\n",
      "Step: 540, acc: 0.984\n",
      "Step: 550, acc: 0.9846\n",
      "Step: 560, acc: 0.9828\n",
      "Step: 570, acc: 0.9825\n",
      "Step: 580, acc: 0.9827\n",
      "Step: 590, acc: 0.9836\n",
      "Step: 600, acc: 0.9833\n",
      "Step: 610, acc: 0.9839\n",
      "Step: 620, acc: 0.9822\n",
      "Step: 630, acc: 0.9848\n",
      "Step: 640, acc: 0.9839\n",
      "Step: 650, acc: 0.9812\n",
      "Step: 660, acc: 0.9823\n",
      "Step: 670, acc: 0.9821\n",
      "Step: 680, acc: 0.9843\n",
      "Step: 690, acc: 0.9862\n",
      "Step: 700, acc: 0.9846\n",
      "Step: 710, acc: 0.9827\n",
      "Step: 720, acc: 0.9848\n",
      "Step: 730, acc: 0.9871\n",
      "Step: 740, acc: 0.9878\n",
      "Step: 750, acc: 0.9866\n",
      "Step: 760, acc: 0.9878\n",
      "Step: 770, acc: 0.986\n",
      "Step: 780, acc: 0.9876\n",
      "Step: 790, acc: 0.9835\n",
      "Step: 800, acc: 0.987\n",
      "Step: 810, acc: 0.9871\n",
      "Step: 820, acc: 0.9882\n",
      "Step: 830, acc: 0.9872\n",
      "Step: 840, acc: 0.986\n",
      "Step: 850, acc: 0.9857\n",
      "Step: 860, acc: 0.9838\n",
      "Step: 870, acc: 0.9859\n",
      "Step: 880, acc: 0.9842\n",
      "Step: 890, acc: 0.9836\n",
      "Step: 900, acc: 0.988\n",
      "Step: 910, acc: 0.9891\n",
      "Step: 920, acc: 0.9878\n",
      "Step: 930, acc: 0.9869\n",
      "Step: 940, acc: 0.9855\n",
      "Step: 950, acc: 0.9875\n",
      "Step: 960, acc: 0.9876\n",
      "Step: 970, acc: 0.9881\n",
      "Step: 980, acc: 0.988\n",
      "Step: 990, acc: 0.9892\n"
     ]
    }
   ],
   "source": [
    "batch_size = 128\n",
    "n_batch = mnist.train.num_examples // batch_size\n",
    "max_step = 1000\n",
    "keep_ = 0.8\n",
    "log_dir = \"Logs/log-6.1\"\n",
    "\n",
    "# 生成权重\n",
    "def weight_variable(shape):\n",
    "    return tf.Variable(tf.truncated_normal(shape,stddev=0.1),name='W')\n",
    "\n",
    "# 生成偏差\n",
    "def bias_vairable(shape):\n",
    "    return tf.Variable(tf.constant(0.1, shape=shape),name='b')\n",
    "\n",
    "# 记录变量\n",
    "def variable_summaries(var):\n",
    "    with tf.name_scope('summaries'):\n",
    "        mean = tf.reduce_mean(var)\n",
    "        tf.summary.scalar('mean', mean)\n",
    "        with tf.name_scope('stddev'):\n",
    "            stddev = tf.sqrt(tf.reduce_mean(tf.square(var-mean)))\n",
    "        tf.summary.scalar('stddev', stddev)\n",
    "        tf.summary.scalar('max', tf.reduce_max(var))\n",
    "        tf.summary.scalar('min', tf.reduce_min(var))\n",
    "        tf.summary.histogram('histogram', var)\n",
    "\n",
    "def conv2d(x,W):\n",
    "    return tf.nn.conv2d(x,W,strides=[1,1,1,1],padding='SAME',name='conv2d')\n",
    "        \n",
    "def conv_layer(input_tensor, weight_shape, layer_name, act=tf.nn.relu):\n",
    "    with tf.name_scope(layer_name):\n",
    "        with tf.name_scope('weights'):\n",
    "            weights = weight_variable(weight_shape)\n",
    "            variable_summaries(weights)\n",
    "        with tf.name_scope('biases'):\n",
    "            biases = bias_vairable([weight_shape[-1]])\n",
    "            variable_summaries(biases)\n",
    "        with tf.name_scope('conv_comput'):\n",
    "            preactivate = conv2d(input_tensor,weights) + biases\n",
    "        with tf.name_scope('activate'):\n",
    "            activations = act(preactivate)\n",
    "        return activations\n",
    "\n",
    "def linear_layer(input_tensor, input_dim, output_dim, layer_name, act=tf.nn.relu):\n",
    "    with tf.name_scope(layer_name):\n",
    "        with tf.name_scope('weights'):\n",
    "            weights = weight_variable([input_dim, output_dim])\n",
    "            variable_summaries(weights)\n",
    "        with tf.name_scope('biases'):\n",
    "            biases = bias_vairable([output_dim])\n",
    "            variable_summaries(biases)\n",
    "        with tf.name_scope('linear_comput'):\n",
    "            preactivate = tf.matmul(input_tensor,weights) + biases\n",
    "        with tf.name_scope('activate'):\n",
    "            activations = act(preactivate)\n",
    "        return activations\n",
    "        \n",
    "\n",
    "def max_pool_2x2(x):\n",
    "    return tf.nn.max_pool(x,ksize=[1,2,2,1],strides=[1,2,2,1],padding='SAME',name='Max_pool')\n",
    "\n",
    "with tf.name_scope('Input'):\n",
    "    x = tf.placeholder(tf.float32,[None,784],name='input_x')\n",
    "    with tf.name_scope('Input_reshape'):\n",
    "        x_image = tf.reshape(x,[-1,28,28,1],name='x-image')\n",
    "        tf.summary.image('input',x_image,10)\n",
    "    y = tf.placeholder(tf.float32,[None,10],name='input_y')\n",
    "    keep_prob = tf.placeholder(tf.float32,name='keep_prob')\n",
    "\n",
    "# 第一次卷积   28*28*1->28*28*32\n",
    "conv_layer1 = conv_layer(x_image,[5,5,1,32],'conv_layer1')\n",
    "# 池化之后变为 14*14*32\n",
    "with tf.name_scope('Max_pool1'):\n",
    "    h_pool1 = max_pool_2x2(conv_layer1)\n",
    "\n",
    "# 第二次卷积 14*14*32->14*14*64\n",
    "conv_layer2 = conv_layer(h_pool1,[5,5,32,64],'conv_layer2')\n",
    "# 第二次池化之后变为 7*7*64\n",
    "with tf.name_scope('Max_pool2'):\n",
    "    h_pool2 = max_pool_2x2(conv_layer2)\n",
    "\n",
    "with tf.name_scope('Flatten'):\n",
    "    flatten_ = tf.reshape(h_pool2,[-1,7*7*64])\n",
    "    \n",
    "# 第一个全连接层 7*7*64 - 1024\n",
    "fc1 = linear_layer(flatten_, 7*7*64, 1024, 'FC1')\n",
    "\n",
    "with tf.name_scope('Dropput'):\n",
    "    fc1_drop = tf.nn.dropout(fc1, keep_prob)\n",
    "    \n",
    "# 第二个全连接层 1024 - 10\n",
    "logits = linear_layer(fc1_drop, 1024, 10, 'FC2',act=tf.nn.sigmoid)\n",
    "\n",
    "with tf.name_scope('loss'):\n",
    "    loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y, logits=logits))\n",
    "    tf.summary.scalar('loss',loss)\n",
    "with tf.name_scope('train'):\n",
    "    train_step = tf.train.AdamOptimizer(0.001).minimize(loss)\n",
    "\n",
    "with tf.name_scope('accuracy'):\n",
    "    prediction = tf.nn.softmax(logits)\n",
    "    correct_prediction = tf.equal(tf.argmax(prediction,1), tf.argmax(y,1))\n",
    "    accuracy = tf.reduce_mean(tf.cast(correct_prediction,tf.float32))\n",
    "    tf.summary.scalar('accuracy', accuracy)\n",
    "    \n",
    "merged = tf.summary.merge_all()\n",
    "\n",
    "def get_dict(train):\n",
    "    if train:\n",
    "        xs, ys = mnist.train.next_batch(batch_size)\n",
    "        k = keep_\n",
    "    else:\n",
    "        xs, ys = mnist.test.images, mnist.test.labels\n",
    "        k = 1.0\n",
    "    return {x:xs, y:ys, keep_prob: k}\n",
    "\n",
    "with tf.Session() as sess:\n",
    "    train_writer = tf.summary.FileWriter(log_dir + '/train', sess.graph)\n",
    "    test_writer = tf.summary.FileWriter(log_dir + '/test')\n",
    "    \n",
    "    sess.run(tf.global_variables_initializer())\n",
    "    \n",
    "    for i in range(max_step):\n",
    "        if i%10 == 0:\n",
    "            summary,acc = sess.run([merged,accuracy], feed_dict=get_dict(False))\n",
    "            test_writer.add_summary(summary, i)\n",
    "            print(\"Step: \" + str(i) + \", acc: \" + str(acc))\n",
    "        else:\n",
    "            summary,_ = sess.run([merged,train_step], feed_dict=get_dict(True))\n",
    "            train_writer.add_summary(summary,i)\n",
    "        \n",
    "    train_writer.close()\n",
    "    test_writer.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
